#pragma once

#include <QWidget>
#include <QMutex>
#include <QImage>
#include <QString>
#include <controller_msgs/msg/visbot_id_box_arr.hpp>

#include "rviz_custom_plugins/av_codec/video_decoder.h"


using rviz_custom_plugins::av_codec::VideoDecoder;
using controller_msgs::msg::VisbotIDBoxArr;

namespace rviz_custom_plugins {

namespace widgets {

class VideoWidget : public QWidget {
    Q_OBJECT
public:
    explicit VideoWidget(QWidget *parent = nullptr);
    void updateFrame(const QImage &frame);
    void setVideoUrl(QString url);
    QString getVideoUrl();
    void start();
    void stop();
    void pause();
    void resume();

    void setVisbotIDBoxArr(const VisbotIDBoxArr::ConstSharedPtr& boxArr);

    QSize sizeHint() const override;

protected:
    void paintEvent(QPaintEvent * event) override;

private:
    QImage currentFrame;
    QMutex mutex;
    VideoDecoder * decoder;
    QString videoUrl;
    std::shared_ptr<VisbotIDBoxArr> boxArrPtr;
    // VisbotIDBoxArr::SharedPtr boxArr;
};

}

}

